<template>
	<view class="container pbsafe_56">
		<view class="box mt_8 text_container">
			<rich-text :nodes="html"></rich-text>
		</view>
		<view class="plr_12 ptb_16 bc_fff">
			<view class="fz_16 fb">
				好物推荐
			</view>
			<view class="flow_x fx mt_8">
				<view class="list_item" v-for="item,index in goodsList" :key="index">
					<GoodsCard type="simple_card" :data="item" :toDetail="false" />
				</view>
			</view>
		</view>
		<view class="pf b_0 l_0 r_0 pt_8 pbsafe_8 plr_16 bc_fff">
			<button class="w100 custom_btn primary lh_40 fz_14 br_57" @click="handleUrl">提交资料成为经销商</button>
		</view>
	</view>
</template>

<script>
	import GoodsCard from '@/components/goods/GoodsCard.vue'
	import api from "@/service/config/api";
	export default {
		components: {
			GoodsCard
		},
		data() {
			return {
				html: '',
				goodsList: [],
				userInfo: this.$storage.getItem('basicUnserInfo') || {},
			}
		},
		onLoad() {
			console.log("进入平台介绍页面")
			this.getData()
		},
		methods: {
			getData() {
				this.$utils.loading()
				Promise.all([this.getInfo(), this.getGoodsList()]).then(() => {
					uni.hideLoading()
				})
			},
			getInfo() {
				return new Promise(resolve => {
					api.get('/base/api/tAppletProtocol/type', {
						key: 'about_us',
					}, {
						noHideLoading: true
					}).then(res => {
						this.html = res.data.valueStr
					}).finally(() => {
						resolve()
					})
				})
			},
			// 获取好物推荐列表
			getGoodsList() {
				return new Promise(resolve => {
					api.get('/goods/api/product/goodProductList', {
						size: 10,
						current: 1,
						userType: this.userInfo.identityType || 1,
						
					...this.$store.state.userInfo.customerId ? {
						customerId: this.$store.state.userInfo.customerId
					} : {},
						orderBy: 0,
					appletType: this.$store.state.appType === this.$base.ADMIN_TYPE ? 0 : 1,
					}, {
						noHideLoading: true
					}).then(res => {
						this.goodsList = res.data && res.data.records ? res.data
							.records : []
					}).finally(() => {
						resolve()
					})
				})
			},
			handleUrl() {
				uni.navigateTo({
					url: '/pages/account/pages/verify'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.text_container{
		padding: 0 32rpx 32rpx 32rpx;
	}
	.list_item+.list_item {
		margin-left: 16rpx;
	}
</style>